package com.longqinuo.mycarservice.utils;


import com.longqinuo.mycarservice.entity.CarBrand;

import java.util.Comparator;

/**
 * Created by zxw on 2016/7/10.
 * 自定义拼音比较器
 */
public class ComparatorPersonToPinYin implements Comparator<CarBrand> {

    @Override
    public int compare(CarBrand lhs, CarBrand rhs) {
        // 只比较两次（暂时只能比较英文）
        if ((lhs.getPinYinName().charAt(0) + "") != null && (rhs.getPinYinName().charAt(0) + "") != null) {
            if ((lhs.getPinYinName().charAt(0) + "").compareTo(rhs.getPinYinName().charAt(0) + "") != 0) {
                return (lhs.getPinYinName().charAt(0) + "").compareTo(rhs.getPinYinName().charAt(0) + "");
            } else {
                if ((lhs.getPinYinName().charAt(1) + "") != null && (rhs.getPinYinName().charAt(1) + "") != null) {
                    return (lhs.getPinYinName().charAt(1) + "").compareTo(rhs.getPinYinName().charAt(1) + "");
                } else {
                    return 0;
                }
            }
        } else {
            return 0;
        }
    }
}
